package com.lz.message.redis;

import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * 消息消费者
 * @author luozhen
 *
 */
public class Consumer implements Runnable {

	private StringRedisTemplate redisTemplate;
	
	private String key;
	
	private static final Logger LOGGER = LoggerFactory.getLogger(Consumer.class);
	
	public Consumer(StringRedisTemplate stringRedisTemplate,String key) {
		this.key = key;
		this.redisTemplate = stringRedisTemplate;
	}
	
	public void run() {
		
		while(true) {
			String value = redisTemplate.opsForList().rightPop(key, 1, TimeUnit.SECONDS);
			LOGGER.info("处理消息：" + value);
		}
		
		
	}	

}
